#pragma strict

var lastTime:float;
var fps:int;
var updateInterval:float;

var frames:int;

function Start(){
	lastTime = Time.realtimeSinceStartup;
}

function Update(){
	frames++;
	var now:float = Time.realtimeSinceStartup;
	if(now >= lastTime + updateInterval){
		fps = frames/(now-lastTime);
		frames = 0;
		lastTime = now;
	}
}

function OnGUI(){
	GUILayout.Box(fps.ToString("f2"));
}